<?php
namespace Portal\Controller;

use Common\Controller\AdminbaseController;

class AdminFeedbackController extends AdminbaseController{

    protected $comments_model;

    public function _initialize(){
        parent::_initialize();
        $this->feedback=D("Common/feedback");
    }

    //用户反馈
    public function index(){
        $where=array();
        $count=$this->feedback->where($where)->count();
        $page = $this->page($count, 20);
        $list=$this->feedback
            ->where($where)
            ->limit($page->firstRow . ',' . $page->listRows)
            ->order("created_time DESC")
            ->select();
        $this->assign("comments",$list);
        $this->assign("page", $page->show('Admin'));
        $this->display("index");
    }
    /**
     * 查看
     */
    public function detail(){
        $id =I('request.id',1,'intval');
        $whereArr = array('id'=>$id);
        $detail = $this->feedback->where($whereArr)->find();
        $this->assign($detail);
        $this->display();
    }
    //后台删除用户反馈
    public function delete(){
        if(isset($_GET['id'])){
            $id = intval(I("get.id"));
            if ($this->feedback->where("id=$id")->delete()!==false) {
                $this->success("删除成功！");
            } else {
                $this->error("删除失败！");
            }
        }
        if(isset($_POST['ids'])){
            $ids=join(",",$_POST['ids']);
            if ($this->feedback->where("id in ($ids)")->delete()!==false) {
                $this->success("删除成功！");
            } else {
                $this->error("删除失败！");
            }
        }
    }


}